﻿#region 命名空间

using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
using Sharp.Platform;
using Sharp.Platform.List;
using Sharp.Platform.Other;
using Column = Ext.Net.MVC.ColumnAttribute;
using DateColumn = Ext.Net.MVC.DateColumnAttribute;
#endregion

namespace Sharp.Web.Models
{
    [Platform.Title("用户组管理")]
    [DataHandler(ModuleOP.Details, "浏览", 0)]
    [DataHandler(ModuleOP.Create, "新增", 1)]
    [DataHandler(ModuleOP.Edit, "修改", 2)]
    [DataHandler(ModuleOP.Delete, "删除", 3)]
    [DataHandler("Permission", "权限", 4)]
    public partial class UserGroupIndexModel
    {
        [Column(Text = "标题", Hidden = true)]
        public Guid Id { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        [Column(Text = "标题")]
        public string Title { get; set; }

        /// <summary>
        ///     备注
        /// </summary>
        [Column(Width = 300, Text = "备注")]
        public string Remark { get; set; }

        [DateColumn(Width = 140, Text = "录入时间", Format = "yyyy-MM-dd HH:mm:ss")]
        public DateTime? CheckInTime { get; set; }


        /// <summary>
        /// 修改时间
        /// </summary>
        [DateColumn(Width = 140, Text = "修改时间", Format = "yyyy-MM-dd HH:mm:ss")]
        public DateTime? ModifiTime { get; set; }

        [Column(Text = "修改人")]
        public string ModifiedUserName { get; set; }

    }

    public partial class UserGroupIndexModel : SharpList
    {
        public UserGroupIndexModel()
        {
            this.Feature = ListFeature.MultiSelect | ListFeature.Paging | ListFeature.RowNumber;

            this.ToolbarButtonParameters.Add(new ToolButtonInfo()
            {
                Model = "Permission",
                Direct = new ToolButtonInfo.DirectClickAction("ListForUserGroup", "Permission"),
                Parameters = new List<ToolButtonInfo.Parameter>()
                {
                    new ToolButtonInfo.Parameter("owner", "userGroup", (int) ParameterMode.Auto),
                    new ToolButtonInfo.Parameter("userGroupId", "this.up('grid').getSelectionModel().getSelection()[0].getData().Id", (int) ParameterMode.Raw),
                    new ToolButtonInfo.Parameter("ownerId", "this.up('grid').getSelectionModel().getSelection()[0].getData().Id", (int) ParameterMode.Raw)
                }
            });
        }
    }
}